#!/usr/bin/perl

require './sharelink-lib.pl';

my ($pid, $err_msg, $log_ev, $log_msg, $log_pri);

$err_msg = "";
$log_ev = "";
$log_msg = "";

&ReadParse();

$pid = $in{"pid"};

#&header($text{'index_title'}, "", "index", 0, 1);

#print $pid;

unless($pid)
{
	$log_ev = $text{'log_ev_smbkillproc_fail_wbpgold'};
	$log_msg= $text{'log_msg_smbkillproc_fail_wbpagold'};
	nas_syslog($text{'modulename'}, 'naslog_warning', $log_ev, $log_msg);
	$err_msg = $text{'smbkillproc_fail_wbpagold'};
	goto ERROR_OUT;
}

unless(&check_pid($pid))
{
	$log_ev = $text{'log_ev_smbkillproc_fail_param'};
	$log_msg= $text{'log_msg_smbkillproc_fail_param'};
	nas_syslog($text{'modulename'}, 'naslog_warning', $log_ev, $log_msg);
	$err_msg = $pid.$text{'smbkillproc_fail_param'};
	#goto ERROR_OUT;
}

my $rt;
$rt = &check_smbproc($pid);
unless($rt)
{
	$log_ev = $text{'log_ev_smbkillproc_fail_wbpgold'};
	$log_msg= $text{'log_msg_smbkillproc_fail_wbpagold'};
	nas_syslog($text{'modulename'}, 'naslog_warning', $log_ev, $log_msg);
	$err_msg = $rt.$text{'smbkillproc_fail_wbpagold'};
	goto ERROR_OUT;
}

#`kill $pid 2>/dev/null`;
my $out = ez_system("kill", $pid);

$log_ev = $text{'log_ev_smbkillproc_ok'};
$log_msg= $text{'log_msg_smbkillproc_ok'};
nas_syslog($text{'modulename'}, 'naslog_info', $log_ev, $log_msg);
redirect("cifs.cgi");

ERROR_OUT:
&error_setup($text{'kill_err_title'});
&error($err_msg);

#&footer("/", $text{'index'});
